﻿<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="UTF-8"%>
<%@ page language="java" import="com.server.web.JsVersionUtil"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<title>后台管理-管理员登录</title>
		<link rel="stylesheet" href='<c:url value="/share/pintuer.css"></c:url>'>
		<link rel="stylesheet" href='<c:url value="/share/admin.css"></c:url>' >
		<script type="text/javascript" src='<c:url value="/js/jquery.js"></c:url>' ></script>
		<script type="text/javascript" src='<c:url value="/js/pintuer.js"></c:url>'></script>
		<script type="text/javascript" src='<c:url value="/js/admin.js"></c:url>'></script>
</head>
	<style>
		.icon-user::before{
			line-height:2.5;!important
		}
		.icon-key::before{
			line-height:2.5;!important
		}
		#_info{
			font-size:12px;
			display:inline-block !important;
			margin:4px 0px;
			padding-left:5px;
		}
	</style>
	<body>
		<div class="container">
			<div class="line">
				<div class="xs6 xm4 xs3-move xm4-move">
					<br />
					<br />
					<div class="media media-y">
						<span>北京市人民政府外事办公室领事保护教育服务平台</span>
						<!-- <a href="http://www.pintuer.com" target="_blank">外事办公室领事保护处教育管理平台</a> -->
					</div>
					<br />
					<br />
				
						<div class="panel">
							<div class="panel-head"><strong>登录后台管理系统</strong></div>
							<div class="panel-body" style="padding:30px;">
								<div class="form-group">
									<div class="field field-icon-right">
										<input type="text" class="input" name="username" placeholder="用户名或手机号" data-validate="required:请填写账号,length#>=1:账号长度不符合要求" />
										<span class="icon icon-user" ></span>
									</div>
								</div>
								<div class="form-group">
									<div class="field field-icon-right">
										<input type="password" class="input" name="password" placeholder="登录密码" data-validate="required:请填写密码,length#>=1:密码长度不符合要求" />
										<span class="icon icon-key" style="line-height:2.5"></span>
									</div>
								</div>
								<div class="form-group">
									<div class="field">
										<input id="codeInputId" type="text" class="input" name="code" placeholder="填写右侧的验证码" data-validate="required:请填写右侧的验证码" />
										<img id="getImg" onclick="changeImg()" src=<c:url value="/code/getCode"></c:url> width="80" height="32" class="passcode" />
									</div>
								</div>
								
									<span id="_info">
									</span>
								
							</div>
							<div class="panel-foot text-center">
								<button id="login" class="button button-block bg-main text-big">立即登录后台</button>
							</div>
						</div>
					
				</div>
			</div>
		</div>

	</body>
	<script type="text/javascript">
	$(function(){
		$(document).keydown(function(event){ 
			if(event.keyCode == 13){ //绑定回车 
				login();
			} 
		}); 
		$("#login").click(function(){
			login();
		});
	});
	function changeImg() {
	    var imgSrc = $("#getImg");
	    var src = imgSrc.attr("src");
	    imgSrc.attr("src", chgUrl(src));
	    $('#codeInputId').val("");
	  }
	  //时间戳   
	  //为了使每次生成图片不一致，即不让浏览器读缓存，所以需要加上时间戳   
	  function chgUrl(url) {
	    var timestamp = (new Date()).valueOf();
	    url = url.substring(0, url.length);
	    if ((url.indexOf("&") >= 0)) {
	      url = url + "×tamp=" + timestamp;
	    } else {
	      url = url + "?timestamp=" + timestamp;
	    }
	    return url;
	  }
	  function login(){
			$.ajax({
				url:"<c:url value='/admin/login'></c:url>",
				type:'post',
				dataType:'json',
				data:{
					"username":$("input[name='username']").val(),"password":$("input[name='password']").val(),
					"code":$("input[name='code']").val()
				},
				success:function(json){
					if(json.isSuccess==true){
						//alert(json.info);
						if(parent.document.getElementById('main_frame')){
							var src = parent.document.getElementById('main_frame').src
							if(src){
								location.href=src;
							}
						}
						else{
							location.href = "<c:url value='/mngindex'></c:url>";
						}
					}else{
						//alert(json.info);
						$("#_info").html("<font color='red'>*"+json.info+"</font>");
						changeImg();
					}
				}
			});
		}
	</script>

</html>
